package com.bizihang.common.security.core.code.sms;

import com.bizihang.common.security.core.code.AbstractValidateCodeGenerator;
import com.bizihang.common.security.core.code.ValidateCode;
import com.bizihang.common.security.core.properties.code.SmsCodeProperties;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.ServletWebRequest;

/**
 * 短信验证码生成器
 *
 * @author 毕子航 951755883@qq.com
 * @date 2018/10/19
 */
@Component("smsValidateCodeGenerator")
public class SmsCodeGenerator extends AbstractValidateCodeGenerator {

	/**
	 * Generate validate code.
	 *
	 * @param request the request
	 * @return the validate code
	 */
	@Override
	public ValidateCode generate(ServletWebRequest request) {
		SmsCodeProperties sms = super.getSecurityProperties().getCode().getSms();
		return new ValidateCode(generatorCode(0), sms.getExpireIn());
	}
}
